<template>
  <div>
    <div class="toolbar">
      <el-input placeholder="请输入内容" v-model="search" clearable style="width:200px" @change="handleSelect">
      </el-input>
      <el-button type="primary" @click="insert">新增用户</el-button>
    </div>
    <el-table :data="tableData" border style="width: 100%">
      <el-table-column prop="date" label="日期" width="180"> </el-table-column>
      <el-table-column prop="name" label="姓名" width="180"> </el-table-column>
      <el-table-column prop="address" label="地址"> </el-table-column>
    </el-table>
    <div>
      <el-pagination background layout="prev, pager, next" :total="total" @current-change="currentChange">
      </el-pagination>
    </div>
  </div>
</template>

<script>
import http from "@/utils/http";
export default {
  data() {
    return {
      tableData: [
        {
          date: "2016-05-02",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
        },
        {
          date: "2016-05-04",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1517 弄",
        },
        {
          date: "2016-05-01",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1519 弄",
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1516 弄",
        },
      ],
      search: "",
      page: 0,
      total: 0,
    };
  },
  mounted() {
    this.getList();
  },
  methods: {
    getList() {
      http.get("/api/select", {
        size: 18,
        page: this.page,
        search: this.search
      }).then((res) => {
        console.log(res);
      });
    },
    handleSelect(e) {
      this.search = e;
      this.getList();
    },
    insert() {
      this.$router.push({ path: '/insert' });
    },
    currentChange() {

    }
  },
};
</script>
<style>
.toolbar {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
}
</style>